package com.qianyu.project.mapper.provider.mfy;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qianyu.project.entity.DeviceMaintain;
import com.qianyu.project.entity.DeviceRequirePlan;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author mfy
 * @desc
 */
public class DeviceMaintainProvider {
    public String Mylist(IPage<DeviceMaintain> page, Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_maintain dm,system_user su,project_info pi");
                WHERE("dm.fill_user=su.id and dm.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("maintainName"))){
                    WHERE("dm.maintain_name like '%"+params.get("maintainName")+"%'");
                }
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("dm.approve_status = '"+params.get("approveStatus")+"'");
                }

            }
        }.toString();
    }

    public String listNopage(Map<String, String> params){
        return new SQL(){
            {
                SELECT("*");
                FROM("device_maintain dm,system_user su,project_info pi");
                WHERE("dm.fill_user=su.id and dm.p_id=pi.id");
                if(!StringUtils.isEmpty(params.get("maintainName"))){
                    WHERE("dm.maintain_name like '%"+params.get("maintainName")+"%'");
                }
                if(!StringUtils.isEmpty(params.get("approveStatus"))){
                    WHERE("dm.approve_status = '"+params.get("approveStatus")+"'");
                }
            }
        }.toString();
    }
}
